<?php
/*
 * 老人个性化显示接口
 */
class Apiv1_IndividuationController extends Ctrl_Apiatk{
    public function indexAction(){
        $p = $_REQUEST;
        $pSid = empty($p['sid'])?Tool_Fnc::ajaxMsg('老人ID不能为空'):Tool_Fnc::safe_string($p['sid']);

        $tMO = new PlanModel;
        $tDatas = array();
        //早上
        $tZsData = $tMO->field('GROUP_CONCAT(event_type) event_type')->where('at = 1 and sid = '.$pSid.' and is_show = 1')->fList();
        $tDatas['zs'] = empty($tZsData[0]['event_type'])?'':$tZsData[0]['event_type'];

        //上午
        $tSwData = $tMO->field('GROUP_CONCAT(event_type) event_type')->where('at = 2 and sid = '.$pSid.' and is_show = 1')->fList();
        $tDatas['sw'] = empty($tSwData[0]['event_type'])?'':$tSwData[0]['event_type'];

        //中午
        $tZwData = $tMO->field('GROUP_CONCAT(event_type) event_type')->where('at = 3 and sid = '.$pSid.' and is_show = 1')->fList();
        $tDatas['zw'] = empty($tZwData[0]['event_type'])?'':$tZwData[0]['event_type'];

        //下午
        $tXwData = $tMO->field('GROUP_CONCAT(event_type) event_type')->where('at = 4 and sid = '.$pSid.' and is_show = 1')->fList();
        $tDatas['xw'] = empty($tXwData[0]['event_type'])?'':$tXwData[0]['event_type'];

        //晚上
        $tWsData = $tMO->field('GROUP_CONCAT(event_type) event_type')->where('at = 5 and sid = '.$pSid.' and is_show = 1')->fList();
        $tDatas['ws'] = empty($tWsData[0]['event_type'])?'':$tWsData[0]['event_type'];
        //视频地址
        $tEMMO = new EventmediaModel;
        $tImgUrl = Yaf_Registry::get('config')->web->url->img;
        $tEmDatas = $tEMMO->field('event_type,concat(\''.$tImgUrl.'\',video) video,video_title')->fList();
        $tDatas['shipin'] = empty($tEmDatas)?array(array()):$tEmDatas;

        Tool_Fnc::ajaxMsg('',1,$tDatas);
    }
    public function allAction(){
        $p = $_REQUEST;
        $pSid = empty($p['sid'])?Tool_Fnc::ajaxMsg('老人ID不能为空'):Tool_Fnc::safe_string($p['sid']);

        $tPMO = new PlanModel;
        $tDatas = array();
        $tPDatas = $tPMO->field('GROUP_CONCAT(event_type) event_type')->where('sid = '.$pSid.' and is_show = 1')->fList();
        //视频地址
        $tEMMO = new EventmediaModel;
        $tImgUrl = Yaf_Registry::get('config')->web->url->img;
        $tEmDatas = $tEMMO->field('event_type,concat(\''.$tImgUrl.'\',video) video,title')->fList();

        $tDatas['shipin'] = empty($tEmDatas)?array(array()):$tEmDatas;
        $tDatas['shijian'] = empty($tPDatas[0]['event_type'])?'':$tPDatas[0]['event_type'];
        $tArr = array_unique(explode(',',$tDatas['shijian']));
        $tDatas['shijian'] = implode(',',$tArr);
        
        Tool_Fnc::ajaxMsg(',',1,$tDatas);
    }
}
?>
